import { K8sNode } from "./node";
import { K8sNamespace } from "./namespace";
import { K8sPod } from "./pod";
import { K8sConfigMap } from "./configmap";
import { K8sIngress } from "./ingress";
import { K8sDaemonSet } from "./daemonset";
import { K8sDeployment } from "./deployment";
import { K8sPersistentVolume } from "./pv";
import { K8sPersistentVolumeClaim } from "./pvc";
import { K8sSecret } from "./secret";
import { K8sService, K8sServiceAccount } from "./service";
import { K8sStatefulSet } from "./statefulset";
import { createLazyObject } from "../../utils";
import { K8sSummary } from "./summary";
import { K8sCluster } from "./cluster";
import { K8sLimitRange, K8sResourceQuota } from "./resourceQuota";
import { Prometheus } from "./metric";
import { RelayServer } from "./relayServer";
import { K8sClusterRole, K8sClusterRoleBinding } from "./clusterRole";
import { K8sReplicasets } from "./replicasets";
import { K8sRoleBinding } from "./roleBinding";
import { K8sWorkload } from "./workload";
import { K8sApiService } from "./apiService";
import { K8sRoleRepo } from "./role";
import { K8sEventRepo } from "./events";
import { K8sStorageClass } from "./storageClass";

export interface K8SApi {
  nodeRepo?: K8sNode;
  namespaceRepo?: K8sNamespace;
  podRepo?: K8sPod;
  configMapRepo?: K8sConfigMap;
  ingressRepo?: K8sIngress;
  daemonSetRepo?: K8sDaemonSet;
  deploymentRepo?: K8sDeployment;
  pvRepo?: K8sPersistentVolume;
  pvcRepo?: K8sPersistentVolumeClaim;
  secretRepo?: K8sSecret;
  serviceRepo?: K8sService;
  serviceAccountRepo?: K8sServiceAccount;
  statefulSetRepo?: K8sStatefulSet;
  summaryRepo?: K8sSummary;
  clusterRepo?: K8sCluster;
  quotasRepo?: K8sResourceQuota;
  limitRangeRepo?: K8sLimitRange;
  metric?: Prometheus;
  relayServer?: RelayServer;
  clusterRoleRepo?: K8sClusterRole;
  replicaSetRepo?: K8sReplicasets;
  roleBindingRepo?: K8sRoleBinding;
  clusterRoleBindingRepo?: K8sClusterRoleBinding;
  workloadRepo?: K8sWorkload;
  apiServiceRepo?: K8sApiService;
  roleRepo?: K8sRoleRepo;
  eventsRepo?: K8sEventRepo;
  storageClassRepo?: K8sStorageClass;
}

const _k8sApi: K8SApi = createLazyObject<K8SApi>({
  nodeRepo: () => new K8sNode(),
  namespaceRepo: () => new K8sNamespace(),
  podRepo: () => new K8sPod(),
  configMapRepo: () => new K8sConfigMap(),
  ingressRepo: () => new K8sIngress(),
  daemonSetRepo: () => new K8sDaemonSet(),
  deploymentRepo: () => new K8sDeployment(),
  pvRepo: () => new K8sPersistentVolume(),
  pvcRepo: () => new K8sPersistentVolumeClaim(),
  secretRepo: () => new K8sSecret(),
  serviceRepo: () => new K8sService(),
  serviceAccountRepo: () => new K8sServiceAccount(),
  statefulSetRepo: () => new K8sStatefulSet(),
  summaryRepo: () => new K8sSummary(),
  clusterRepo: () => new K8sCluster(),
  quotasRepo: () => new K8sResourceQuota(),
  limitRangeRepo: () => new K8sLimitRange(),
  metric: () => new Prometheus(),
  relayServer: () => new RelayServer(),
  clusterRoleRepo: () => new K8sClusterRole(),
  replicaSetRepo: () => new K8sReplicasets(),
  roleBindingRepo: () => new K8sRoleBinding(),
  clusterRoleBindingRepo: () => new K8sClusterRoleBinding(),
  workloadRepo: () => new K8sWorkload(),
  apiServiceRepo: () => new K8sApiService(),
  roleRepo: () => new K8sRoleRepo(),
  eventsRepo: () => new K8sEventRepo(),
  storageClassRepo: () => new K8sStorageClass()
});

export const useK8SApi = () => {
  return _k8sApi;
};
